package com.study.selection.service;

import com.study.selection.dao.MajorDao;
import com.study.selection.model.Major;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;

@Service
public class MajorServiceImpl implements MajorService {

    @Autowired
    private MajorDao majorDao;

    @Override
    public List<Major> findAll() {
        return majorDao.findAll();
    }

    @Override
    public List<Major> findByKey(String key) {
        return majorDao.findByKey(key);
    }

    @Override
    public boolean addMajor(Major major) {
        return majorDao.addMajor(major) > 0 ? true : false;
    }

    @Override
    public List<Major> getByCollegeId(int collegeId){
        return majorDao.getByCollegeId(collegeId);
    }
    @Override
    public Major getByMajorId(int majorId) {
        return majorDao.getByMajorId(majorId);
    }

    @Override
    public boolean updateMajor(Major major) {
        return majorDao.updateMajor(major) > 0 ? true : false;
    }
    @Override
    public boolean deleteMajor(int majorId) {
        return majorDao.deleteMajor(majorId) > 0 ? true : false;
    }


}
